import qs from "query-string";
import request from "./request";
import { iQueryTokenParams } from "@services/index";
import { iGetDataParams } from "@/pages/homepage/types";

const METHOD = {
  GET: 'get',
  POST: 'post',
  PUT: 'put',
  DELETE: 'delete'
};

const ISNEEDTOKEN = {
  TRUE: true,
  FALSE: false,
}
const ISQUERYPOST = {
  TRUE: true,
  FALSE: false,
}
export const isDev = false;
const API_EVENTTRACK = "http://big.data.alilo.com.cn/track/app";
const API_DOMAIN = isDev ? 'http://api-dcloud.alilo.com.cn' : 'http://api.cloud.alilo.com.cn';
const API_PREFIX = `${API_DOMAIN}/api/v4`;

const getApi = (url: string): string => API_PREFIX + url;
export default {
  queryToken: (params: iQueryTokenParams) => request(getApi(`/login/get-token`), params, METHOD.GET, ISNEEDTOKEN.FALSE, ISQUERYPOST.FALSE, false, false),
  queryAlbum: (params: iGetDataParams) => request(getApi(`/audio-group/get`), params, METHOD.POST, ISNEEDTOKEN.TRUE, ISQUERYPOST.FALSE, false, false),
  uploadEventTracks: (params: any) => request(API_EVENTTRACK, params, METHOD.POST, ISNEEDTOKEN.FALSE, ISQUERYPOST.FALSE, false, false),
};
